<?php

namespace Admin\Models\log;

use Admin\Models\BaseModel;
class XhlogError extends BaseModel
{

    /**
     *
     * @var integer
     */
    public $iErrorId;

    /**
     *
     * @var string
     */
    public $sControllerName;

    /**
     *
     * @var string
     */
    public $sMethodName;

    /**
     *
     * @var string
     */
    public $mRequestParam;

    /**
     *
     * @var string
     */
    public $mErrorMessage;

    /**
     *
     * @var string
     */
    public $tCreateDate;

    /**
     *
     * @var string
     */
    public $iUserId;

    /**
     *
     * @var string
     */
    public $sUserIP;

    /**
     *
     * @var string
     */
    public $sUserOS;

    /**
     *
     * @var string
     */
    public $sUserBrowser;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->setSource("XHLog_Error");
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'XHLog_Error';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return XhlogError[]
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return XhlogError
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    /**
     * 根据id删除记录并返回结果
     *
     * @param $idArr
     * @return mixed
     *
     * create by ck 20161021
     */
    public static function deleteRecordById($idArr)
    {
        return self::find([
            'conditions'    => 'iErrorId IN ({idArr:array})',
            'bind'          => [
                'idArr'         => $idArr
            ]
        ])->delete();
    }

}
